/**
 * 
 */
package Media.ui.widgets.DeviceView;

import java.util.concurrent.ConcurrentHashMap;

import org.eclipse.swt.widgets.TreeItem;

/**
 * Tree Item Properties contained class.
 * @author Hardeep
 */
public class ItemProp {
	public static final int FILE = 0;
	public static final int FOLDER = 1;

	/**
	 * The treeItem that this ItemProp represents
	 */
	public TreeItem treeitem = null;
	/**
	 * This items parent.
	 */
	public TreeItem parent = null;
	/**
	 * The type of item this is, see constants.
	 */
	public int itemType = FILE;
	/**
	 * Any child objects this item may have. It may only have child objects if
	 * it is a FOLDER.
	 */
	public ConcurrentHashMap<TreeItem, ItemProp> childs = 
		new ConcurrentHashMap<TreeItem, ItemProp>();

	public ItemProp() {}

	public ItemProp(TreeItem parent, TreeItem item, int itemType) {
		this.parent = parent;
		treeitem = item;
		this.itemType = itemType;
	}

	public ItemProp addChild(TreeItem item) {
		return addChild(item, new ItemProp());
	}

	public ItemProp addChild(TreeItem item, ItemProp props) {
		if ( itemType == FOLDER ) {
			childs.put(item, props);
			return props;
		}
		return null;
	}

	public ItemProp getChild(TreeItem item) {
		if ( childs.contains(item) ) {
			return childs.get(item);
		}
		return null;
	}
}
